import React from "react";
import {Row,Col} from "antd";

import "../../css/component.less";
import Cenav from "./cenav";

export default class ImgText extends React.Component{
    constructor(props){
        super(props);
        
        this.state={
            imgnews:[],
            type:props.data,
            count:props.count
            
        }
    }
    componentDidMount(event){
        let result=fetch("http://www.wwtliu.com/sxtstu/news/juhenews.php?type="+this.state.type+"&count="+this.state.count,{
            method:"get"
        }).then(rel=>{
            return rel.json();
        }).then(json=>{
            this.setState({
                imgnews:json
            })
           
        })
       
    }
   
    render(){
        console.log(this.state.imgnews)
        return(
            <div className="component" >
               <Row>
                <Col span={16}>
                   <ul>
                        {
                            this.state.imgnews.map((item,index)=>{
                                return (
                                    <li key={index}>
                                        <img src={item.thumbnail_pic_s}/>
                                        <span>{item.title} </span>
                                        <span>{item.date}</span>
                                        <span>作者：{item.author_name}</span>
                                    </li>
                                )
                            })
                        }
                   </ul>
                </Col>
                <Col span={8}>
                    <Cenav  data={this.state.type} count={this.state.count}/>
                </Col>
               </Row>  
               
            </div>

        )
    }
}